package com.xjzd.practice.statemachine;

public enum OrderState {
    COMPLETED("已完成"),

    @Transition(
            source = SHIPPED,
            event = OrderEvent.CONFIRM_RECEIPT,
            target = COMPLETED,
            action = CompletionAction.class
    )
    SHIPPED("已发货"),

    CANCELLED("已取消"),
    @Transition(
            source = PAID,
            event = OrderEvent.SHIP,
            target = SHIPPED,
            action = ShipAction.class
    )
    PAID("已支付"),

    @Transition(
            source = PENDING_PAYMENT,
            event = OrderEvent.PAY,
            target = PAID,
            action = PayAction.class
    )
    @Transition(
            source = PENDING_PAYMENT,
            event = OrderEvent.CANCEL,
            target = CANCELLED,
            action = CancelAction.class
    )
    PENDING_PAYMENT("待支付");

    private final String desc;

    OrderState(String desc) {
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }
}
